package com.github.xuchen93.forlaozeng.opreate_3;

/**
 * @author xuchen.wang
 */
public class Subject_5 {

	/**
	 * 利用编程语言，把输入的字符串str1中的内容逆置，并保存到字符串str2中，输出str2的内容。例如：str1=“abc”，str2则为"cba"
	 */
	public static void main(String[] args) {
		String str1 = "a";
		String str2 = revert(str1);
		System.out.println(str2);
	}

	public static String revert(String str1){
		char[] chars = str1.toCharArray();
		for (int i = 0; i < chars.length/2; i++) {
			char temp = chars[chars.length-1-i];
			chars[chars.length-1-i] = chars[i];
			chars[i] = temp;
		}
		return new String(chars);
	}
}
